package cn.wolfcode.web.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class   CheckLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object user_in_session = request.getSession().getAttribute("USER_IN_SESSION");
        if (user_in_session != null) {
            return true;
        }
        response.sendRedirect("/login.html");
        return false;
    }
}
